/*
 * @Author: szx
 * @Date: 2022-02-18 13:18:55
 * @LastEditTime: 2022-02-18 13:24:20
 * @Description:
 * @FilePath: \leetcode\200-299\203\203_2.js
 */
function ListNode(val, next) {
    this.val = val === undefined ? 0 : val;
    this.next = next === undefined ? null : next;
}
/**
 * @param {ListNode} head
 * @param {number} val
 * @return {ListNode}
 */
 var removeElements = function (head, val) {
    let prev = new ListNode(0, head);
    let cur = prev;
    while (cur!=null && cur.next != null) {
        if (cur.next.val == val) cur.next = cur.next.next;
        else cur = cur.next;
    }
    return prev.next;
};
